package com.vogue.supplymall.order.domain.dao.impl;

import com.vogue.supplymall.common.domain.dto.EditCartInfo;
import com.vogue.supplymall.common.domain.dto.OrderDetailInfo;
import com.vogue.supplymall.common.domain.dto.OrderInfo;
import com.vogue.supplymall.common.domain.dto.RelevanceInfo;
import com.vogue.supplymall.order.domain.dao.OrderItemProductDao;
import com.vogue.supplymall.order.domain.mapper.OrderItemProductMapper;
import com.vogue.supplymall.order.domain.model.OrderItemProduct;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The type Order item product dao.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-01-10
 */
@Repository("orderItemProductDao")
public class OrderItemProductDaoImpl extends BaseDaoImpl<OrderItemProduct, Long> implements OrderItemProductDao {
    @Resource
    private OrderItemProductMapper orderItemProductMapper;

    @Override
    public List<Map<String, Object>> findCart(EditCartInfo editCartInfo) {
        return orderItemProductMapper.findCart(editCartInfo);
    }

    @Override
    public Long findCartCount(EditCartInfo editCartInfo) {
        return orderItemProductMapper.findCartCount(editCartInfo);
    }

    @Override
    public List<Map<String, Object>> findOrder(OrderInfo orderInfo) {
        return orderItemProductMapper.findOrder(orderInfo);
    }

    @Override
    public List<Map<String, Object>> findOrderProduct(OrderDetailInfo orderDetailInfo) {
        return orderItemProductMapper.findOrderItem(orderDetailInfo);
    }

    @Override
    public OrderItemProduct getOrderItemProductBySql(Long orderid, Long productid, Long attrplanid, Long storageid) {
        List<OrderItemProduct> lists = orderItemProductMapper.findOrderItemProduct(orderid, productid, attrplanid, storageid);
        return (lists.size() < 1) ? null : lists.get(0);
    }

    @Override
    public Long getItemAndStorage(EditCartInfo editCartInfo) {
        return orderItemProductMapper.getItemAndStorage(editCartInfo);
    }


}
